package com.gms.controller.equipmanger;


import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.gms.entity.equipment.Equipmenttype;
import com.gms.service.equipmanager.EquipmenttypeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.lang.Nullable;
import org.springframework.ui.Model;
import org.springframework.util.StringUtils;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author jianghai
 * @since 2021-06-14
 */
@RestController
@RequestMapping("/equipmenttype")
public class EquipmenttypeController {


    @Autowired
    EquipmenttypeService equipmenttypeService;

    //根据器材名字和器材种类id查询
    @RequestMapping("/query")
    public String queryEquipment(@Nullable String etypename,
                                 @Nullable Integer etypeid,
                                 @Nullable Integer pageNum,
                                 Model model) {
        if (pageNum == null) pageNum = 1;
        if (!StringUtils.isEmpty(etypename)) {
            model.addAttribute("etypename",etypename);
        }
        if (etypeid != null) {
            model.addAttribute("etypeid",etypeid);
        }
        Page<Equipmenttype> page = equipmenttypeService.query_equip(etypename,etypeid,pageNum);
        model.addAttribute("page",page);
        return "equipment";
    }

}

